package com.paperobot.dao;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ibatis.sqlmap.client.SqlMapClient;


public abstract class BaseDao extends SqlMapClientDaoSupport {
	
	protected final Logger logger = LoggerFactory.getLogger(getClass());

	@Resource(name="sqlMapClient")
    public void setSqlMapClientBase(SqlMapClient sqlMapClient) {  
        super.setSqlMapClient(sqlMapClient);  
    }

	protected Object getObject(String id, Object paramObject) throws Exception{
		return getSqlMapClientTemplate().queryForObject(id, paramObject);
	}
	
	protected List<?> getObjects(String id, Object paramObject) throws Exception{
		return getSqlMapClientTemplate().queryForList(id, paramObject);
	}
	
	protected Object saveObject(String id, Object paramObject) throws Exception{
		return getSqlMapClientTemplate().insert(id, paramObject);
	}
	
	protected int updateObject(String id, Object paramObject) throws Exception{
		return getSqlMapClientTemplate().update(id, paramObject);
	}
	
	protected int deleteObject(String id, Object paramObject) throws Exception{
		return getSqlMapClientTemplate().delete(id, paramObject);
	}
	
}
